$(function () {
    $('.search .input input').bind('keyup', function (e) { //输入框按下按键事件
        if ($(this).val() == '') { //输入框内容为空,清除推荐搜索词
            $('.search .search_list').html('');
            $('.search .search_list').hide();
            $('.search .input .host_search').hide();
            
            
            
            return;
        }
        if (e.keyCode == "13") { //按下回车按钮
            if ($('.search .search_list span.hover').length > 0) { //推荐搜索词有选中状态，吧选中状态的文本填充到搜索框  然后清除推荐搜索词
                search_listId = -1;
                $(this).val($('.search .search_list span.hover b').html());
                $('.search .search_list').hide();
                $('.search .input .host_search').hide();
                $('.search .search_list').html('');
                return;
            }
            //            console.log('搜索');
            jumpSearch();
            return;
        }
        if (e.keyCode == "40") { //方向下按钮，
            //            console.log('方向下键');
            if (search_listId == $('.search .search_list span').length - 1) {
                search_listId = -1;
            }
            search_listId += 1;
            $('.search .search_list span').removeClass('hover');
            $('.search .search_list span').eq(search_listId).addClass('hover');
            //            $(this).val($('.search .search_list span.hover b').html());
            return;
        }
        if (e.keyCode == "38") {
            //            console.log('方向上键');
            if (search_listId == 0) {
                search_listId = $('.search .search_list span').length;
            }
            search_listId -= 1;
            $('.search .search_list span').removeClass('hover');
            $('.search .search_list span').eq(search_listId).addClass('hover');
            //            $(this).val($('.search .search_list span.hover b').html());
            return;
        }
        setSearchList(ssc);
    });
    $('.search .input input').bind('focus', function (e) { //搜索框获取焦点事件
        if ($(this).val() == '') {
            return;
        }
        setSearchList(ssc);
    });
    $('.search .input input').bind('blur', function (e) {
        if ($('.search .search_list span.hover').length > 0) { //推荐搜索词有选中状态
            return;
        }
        search_listId = -1;
        $('.search .search_list').hide();
        $('.search .input .host_search').hide();
    });
    $('.search .search_list').on('mouseover', 'span', function () {
        $('.search .search_list span').removeClass('hover');
        search_listId = $(this).index('.search .search_list span');
        $(this).addClass('hover');
    });
    $('.search .search_list').on('mouseout', 'span', function () {
        $('.search .search_list span').removeClass('hover');
        search_listId = -1;
    });
    $('.search .search_list').on('click', '.hover', function () {
        $('.search .input input').val($(this).find('b').html());
        $('.search .search_list').html('');
        $('.search .search_list').hide();
        $('.search .input .host_search').hide();
    });

    $('.search .input .select').click(function () {
        $('.search .input .select').toggleClass('open');
        $('.search .input .select .option').slideToggle(100);
    });
    $('.search .input .select .option').click(function (event) {
        event.stopPropagation();
    });
    $('.search .input .select .option li').click(function (event) {
        $('.search .input .select .value').attr('value', $(this).attr('value'));
        $('.search .input .select .value').html($(this).html() + '<i class="mdui-icon material-icons">play_arrow</i>');
        $('.search .input .select').toggleClass('open');
        $('.search .input .select .option').slideToggle(100);
    });
    $('.search .input .button').click(function () {
        jumpSearch();
    });



    /*广告容器加载*/
    var adBox = new Swiper('.ad_box_item', {
        pagination: {
            el: '.ad_box_pages',
        },
        loop: true,
        autoplay:true,
        
    });
})
